%% -*- mode: nitrogen -*-
-module (assembler_web).
-compile(export_all).
-include_lib("nitrogen_core/include/wf.hrl").
-include("records.hrl").

main() -> #template { file="./site/templates/bare.html" }.

title() -> "Mano assembler".

body() ->
    [
     #panel { style="margin: 10px 10px;", body=[
            #span { text="Enter Assembly code:" },
     #br{},
     #inplace_textbox { text="Please Enter file name" },
     #panel { id=placeholder }
     ]}
     ].

%event(click) ->
    %Text = wf:q(codePlace),
    %assembler:first_pass(Text),
    %wf:update(placeholder, Text).

event(_) ->
    ok.


inplace_textbox_event(_Tag, Value) ->
    Result = assembler:first_pass(Value),
    io:format("~p~n",[Result]),
    display(Result),
    Value.

display([]) ->
    ok;
display([{Loc, Code}|T]) ->
    wf:insert_bottom(placeholder, Loc ++ "    " ++Code++"<br>"),
    display(T).

